var myGrid;
$(function(){
	myGrid = $("#list").jqGrid({
			url : "archivedocument/archive-document!datalist",
			datatype : "json",
			mtype : 'GET',
			colNames : [
			   'PDF文件',
			   'WORD文件',
			   '表单',
			   '归档者',
			   '归档日期'			   
			],
			colModel : [
			      {
					name : 'id',
					index : 'id',
					width : 50,
					formatter:pdfFormatter
				  },
				  {
						name : 'workflowId',
						index : 'workflowId',
						width : 50,
						formatter:wordFormatter
				  },
			      {
						name : 'workflowId',
						index : 'workflowId',
						width : 50,
						formatter:formFormatter
			      },
			      {
					name : 'executor',
					index : 'executor',
					width : 100,
					formatter:nameFormatter
				  },
			      {
					name : 'createDate',
					index : 'createDate',
					width : 100			
				  }
			      
			],
			pager : '#pager',
			rowNum : 10,
			rowList : [ 10, 20, 30 ],
			sortname : 'name',
			sortorder : 'asc',
			viewrecords : true,
			caption : "归档文件列表",
			width : '750',
			height : '300',
			jsonReader : {
				repeatitems : false,
				id : "0"
			}
		});	
});
function nameFormatter(v,opt,row){
	return v.localName;
}
function pdfFormatter(v,opt,row){
	var url=navObj.archivedocument.core+navObj.archivedocument.view+"?bean.id="+v;
	var link=$("<a onclick='openDoc(\""+url+"\");return false;' href='javascript:;'>浏览PDF</a>");
	return $("<p></p>").append(link).html();
}
function wordFormatter(v,opt,row){
	var wid = row['workflowId'];
	var url = navObj.admin.office.core+navObj.admin.office.viewcollate+"?workflowId="+wid;
	//window.open(url,"colwin");
	var link=$("<a onclick='openDoc(\""+url+"\");return false;' href='javascript:;'>浏览WORD</a>");
	return $("<p></p>").append(link).html();
}
function formFormatter(v,opt,row){
	var wid = row['workflowId'];
	var rparam = "ba83b88c_fdd6_46a8_89df_08949141ad2b9fbaa3ec_4ed2_4b78_9349_bfa802bf7912b4ac35ae_f1db_4081_bff5_57c04a839282b38388d2_467b_45fd_bfde_a58eb25a3c2ca50a51b8_9a75_493d_a8cc_52e7690cc8b34d896dfd_cc27_4ca8_9276_1e9f5c8bdf80dd7c4b5f_c730_48c5_9814_4a04babc7bd3543c234d_8d67_406f_b85f_dfe2949f270cbd719c0b_6992_48d2_a979_eef25873212f710d9509_19e5_4fbe_b20c_64662a6985bb=SDFSDFDSFDHFJHFDSFH^FT^SDF655";
	var url = navObj.form.show.core+navObj.form.show.showform+"?"+rparam+"&workflowId="+wid+"&showOnly=true";
	var link=$("<a onclick='openDoc(\""+url+"\");return false;' href='javascript:;'>浏览HTML</a>");
	return $("<p></p>").append(link).html();
}

function openDoc(url){
	window.open(url,"colwin");	
}